package com.yang;

import java.io.*;
import java.util.Objects;

public class C {
    private StringBuffer stringBuffer = null;
    private FileReader fileReader = null;
    private BufferedReader bufferedReader = null;

    protected String read(){
        File file = new File(A.TMP);
        String str = "";
        System.out.println("开始读取数据,文件路径为:"+file.getPath()+"~~~~~~~~~~");
        try {
            fileReader = new FileReader(file);
            bufferedReader = new BufferedReader(fileReader);
            stringBuffer = new StringBuffer();
            while ((str = bufferedReader.readLine())!=null){
                stringBuffer.append(str);
            }

            System.out.println("读取数据完成~~~~~~~~~~");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (Objects.nonNull(bufferedReader)) {
                    bufferedReader.close();
                }
                if (Objects.nonNull(fileReader)){
                    fileReader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return stringBuffer.toString();
    }
}
